package com.example.demo.day0306;

public class DemoInterrupt {
    public static class Interrupt_demo1 extends Thread{

        @Override
        public void run() {
            System.out.println("线程"+Thread.currentThread().getName()+"在运行~~~~");

        }
    }

    public static void main(String[] args) {

        for (int i = 0; i < 10; i++) {
            Thread thread=new Interrupt_demo1();
            thread.start();
            if (i%2==0) {
                thread.interrupt();// interrupt()方法只是改变中断状态，不会中断一个正在运行的线程。
            }
        }
    }

}
